using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Universe.WinForms.Broadcast;

namespace Universe.WinForms.Test
{
    public partial class Form1 : Form
    {
        private DeviceChangedListener _listener;

        public Form1()
        {
            InitializeComponent();
            // this.indeterminateProgressBar1.PipHeight = 10;
            // this.indeterminateProgressBar1.Start();

            ToolStripIndeterminateProgressBar pb = new ToolStripIndeterminateProgressBar();
            // pb.AutoSize = false;
/*
            pb.Width = 333;
            pb.ProgressBar.Width = 333;
            pb.ProgressBar.Pips = 10;
            pb.ProgressBar.Start();
*/
            pb.Margin = new Padding(0,5,0,statusStrip1.Height - pb.Height - 5);
            pb.Running = true;
            pb.Size = new Size(100,5);
            this.statusStrip1.Items.Add(pb);

            Debug.WriteLine("PB Size: " + pb.ProgressBar.Size);

            SatisfactoryToolStripRenderer.Bind(this.toolStrip1, this.toolStripButton3);

            _listener = new DeviceChangedListener();
            // _listener.DeviceChanged += listener_DeviceChanged;
            _listener.DeviceArrived += new DeviceChangedEventHandler(_listener_DeviceArrived);
            _listener.DeviceRemoved += new DeviceChangedEventHandler(_listener_DeviceRemoved);
        }

        void _listener_DeviceRemoved(object sender, DriveDetectorEventArgs e)
        {
            listener_Display("Removed", e.Drive);
        }

        void _listener_DeviceArrived(object sender, DriveDetectorEventArgs e)
        {
            listener_Display("Arrived", e.Drive);
        }

        void listener_Display(string kind, string drive)
        {
            ListViewItem item = new ListViewItem(kind + ": " + drive);
            listView1.Items.Add(item);
            item.EnsureVisible();
        }

        private void roundButton7_Click(object sender, EventArgs e)
        {
            new FormRoundButtons().Show(this);
        }
    }
}